package com.mzj.demo.dao;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.mzj.demo.entity.User;

public interface UserRepository extends JpaRepository<User, Integer> {
	public User findByName(String name);
	
	@Query("select u from User u where u.name=?1 ")
	public User findUserByDepartment(String name);
	
	@Query(value="select * from user where name=?1 ",nativeQuery=true)
	public User nativeQuery(String name);
	
	@Query(value="select * from user where name=:name ",nativeQuery=true)
	public User nativeQuery2(@Param("name")  String name);

	@Query(value="select count(1) total from user ",nativeQuery=true)
	public List<Object[]> queryUserCount();
	
	@Query(value="select id from user ",nativeQuery=true)
	public List<Integer> queryUserIds();
	
	@Query(value="select u from User u ")
	public Page<User> queryUsers(Pageable page);

}
